package com.shuinfo.controller;

import com.alibaba.fastjson.JSON;
import com.shuinfo.bean.ao.WechatCheckUserStatusAO;
import com.shuinfo.bean.ao.WechatLeadLoginAO;
import com.shuinfo.core.ApiResult;
import com.shuinfo.service.UserService;
import com.shuinfo.service.WechatService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RequestMapping("api/wechat/")
@Slf4j
@RestController
public class WechatController {

    @Resource
    private UserService userService;

    @Resource
    private WechatService wechatService;

    @GetMapping("detail")
    public ApiResult detail(@RequestParam Integer id){
        log.info("AppInfoController detail is:{}", id);

        return ApiResult.ok(userService.detailById(id));
    }

    @PostMapping("checkUserStatus")
    public ApiResult checkUserStatus(@RequestBody WechatCheckUserStatusAO req){
        log.info("AppInfoController checkUserStatus WechatCheckUserStatusAO:{}", JSON.toJSONString(req));

        return ApiResult.ok(wechatService.checkUserStatus(req.getCode(), req.getParamId()));
    }

    @PostMapping("leadLogin")
    public ApiResult leadLogin(@RequestBody WechatLeadLoginAO req){
        log.info("AppInfoController checkUserStatus WechatLeadLoginAO:{}", JSON.toJSONString(req));

        return ApiResult.ok(wechatService.leadLogin(req));
    }

    @PostMapping("getPacket")
    public ApiResult getPacket(@RequestBody WechatLeadLoginAO req){
        log.info("AppInfoController getPacket WechatLeadLoginAO:{}", JSON.toJSONString(req));

        return ApiResult.ok(wechatService.leadLogin(req));
    }

}
